%clc;
clear
C=[1 1 1 1 0 1];
X=[0 0 1 0 1 1];
h=6;
%M=0;
mod2=[0 1;1 0];
%--------------------------------------------------------------------------------

for j=1:1:500;
XX(1)=mod2(mod2(mod2(C(1)*X(1)+1,C(2)*X(2)+1)+1,mod2(C(3)*X(3)+1,C(4)*X(4)+1)+1)+1,mod2(C(5)*X(5)+1,C(6)*X(6)+1)+1);
XX(2)=X(1);
XX(3)=X(2);
XX(4)=X(3);
XX(5)=X(4);
XX(6)=X(5);

X=XX;
M(j)=X(h);
end;
M(1:70)
%----------------------------------------------------------------------------------

N=31;  S=0;
for mu=1:1:N-1;
for n=mu+1:1:N;
S=S+M(n)*M(n-mu);
end;
Ra(mu)=S/N;
S=0;
end;

fic1=figure;
grid on;
plot(Ra);
pause;
close(fic1);

%---------------------------------------------------------------------------------

N=150;  S=0;
for mu=0:1:N-1;
for n=1:1:N;
S=S+M(n)*M(n-mu+310);
end;
Rn(mu+1)=S/N;
S=0;
end;
fic2=figure;
grid on;
plot(Rn);
pause;
close(fic2);

%------------------------------------------------------------------------------
vzaim;
